<template>
	<view>
		<view class="body-form">
		<form @submit="formSubmit" @reset="formReset" >
			<view class="uni-form-item uni-column">
				<span style="margin-top: 20px;float: left;margin-left: 20px;font-size: 18px;color: #888888">请说明你的症状</span>
				<view class="input-inbox">
					<input class="input" placeholder-class="placeholder-class" 
					placeholder="发烧/头痛/腿疼/腰疼/肚子疼等" name="input"/>
				</view>
			</view>
			<view class="uni-form-item uni-column">
			</view>
			<view class="uni-btn-v">
				<button class="button"   form-type="submit">立即提交</button>
				<button class="button"  form-type="reset">清空</button>
			</view>
		</form>
		</view>
	</view>
</template>

<script>
	import { requestURL } from '../../../common/utils/config.js';
	import { getToken } from '../../../common/utils/auth.js';
	export default {
		data() {
			return {}
		},
		methods: {
			formSubmit: function(e) {
				var symptoms = e.detail.value.input
				var user = 'people1';
				
				var apiUrl = requestURL+'doctor/recommand?yonghu='+user+'&miaoshu='+symptoms;
				
				uni.request({
					url: apiUrl,
					method:'get',
					header: {
						'Authorization': getToken() || ''
					},
					success: (res) => {
						var doctorList = [];
						if(res.data.flag=="SUCCESS"){
							doctorList = res.data.doctorlist
							console.log(doctorList);
							uni.setStorageSync("doctorList",JSON.stringify(doctorList));
							
							console.log(99999);
							uni.navigateTo({
								url: '/pages/yuyue/doctorRecommend/doctorRecommendList' 
							})
						}
						else if(res.data.falg=="ERROR_INPUT"){
							uni.showModal({
								content: '输入有误',
								showCancel: false
							});
							
						}
						else if(res.data.falg=="NO_RESULT"){
							uni.showModal({
								content: '暂无推荐',
								showCancel: false
							});
							
						}
					},
					fail: (err) => {
						console.log('request fail', err);
						uni.showModal({
							content: err.errMsg,
							showCancel: false
						})
					}
				});
				
			},
			formReset: function(e) {
				console.log('清空数据')
			}
		}
	}
</script>

<style scoped lang="scss">
	.header {
		height: 60px;
		width: auto;
		background-color: #7ec0ee;
		color: #FFFFFF;
	
	}
	.uni-form-item .title {
		padding: 20rpx 0;
	}
	
	.body-form{
		width: 90%;
		margin: 0 auto;
		
		height: 400px;
	}
	.inputSym{
		height: 40px;
		width: 90%;
		margin: 0 auto;
		
	}
	
	@import '@/common/scss/form.scss';
	@import '@/common/scss/common.scss';
	
	page {
		width: 100%;
		height: 100%;
		background-color: #F2F2F2;
	}
	
	@mixin mt($top) {
		margin-top: $top;
	}
	
	.input-inbox {
		@extend .input-box;
		@include mt(80rpx);
		display: flex;
		align-items: center;
		height: 100px;
		
	
		.input {
			@include width-margin(90%, 90%);
		}
	}
	
	
	
	// 登录按钮
	.button {
		@extend .button-box;
		@include mt(50rpx);
		
		
	}
	
	
</style>
